package com.exartisan.thanhdoanhn;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.exartisan.thanhdoanhn.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {
	Intent intent;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		getKeyHash();
	}
	public void handleEvent(View v){
		intent=new Intent(this,HomeActivity.class);
		intent.putExtra("KEY", 0);
		startActivity(intent);
	}
	public void handleBlog(View v){
		intent=new Intent(this,HomeActivity.class);
		intent.putExtra("KEY", 1);
		startActivity(intent);
	}
	public void handleGallary(View v){
		intent=new Intent(this,HomeActivity.class);
		intent.putExtra("KEY", 2);
		startActivity(intent);
	}
	public void getKeyHash(){
		try {
		    PackageInfo info = getPackageManager().getPackageInfo(
		            "com.exartisan.thanhdoanhn", 
		            PackageManager.GET_SIGNATURES);
		    for (Signature signature : info.signatures) {
		        MessageDigest md = MessageDigest.getInstance("SHA");
		        md.update(signature.toByteArray());
		        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
		        }
		} catch (NameNotFoundException e) {

		} catch (NoSuchAlgorithmException e) {

		}
	}
	

}
